#ifndef UTIL_H
#define UTIL_H

#include <inttypes.h>

typedef union{

  uint16_t  word;

  struct{

    uint16_t byteL :8;
    uint16_t byteH :8;

  }bytes;

}WORD_t;

typedef	union
{
    int32_t long_word;

    struct LONG_WORD
    {
        int32_t byteHH	:8;
        int32_t byteMH	:8;
        int32_t byteML	:8;
        int32_t byteLL	:8;
    }bytes;

}LONG_WORD_t;

enum Alloc
{
    FEATURE_FREE		= 0,
    FEATURE_UTILIZED	= 1
};

enum DDR
{
    DIGITAL_INPUT		= 0,
    DIGITAL_OUTPUT      = 1
};

typedef enum{
	OPP_FAILED	= 0,
	OPP_SUCCESSFUL	= 1
}status_t;

typedef enum GAIN_ENUM
{
    ADC_CH_GAIN_OFF_gc  = 0,
    ADC_CH_GAIN_1X_gc   = 1,
    ADC_CH_GAIN_2X_gc   = 2,
    ADC_CH_GAIN_4X_gc   = 3,
    ADC_CH_GAIN_8X_gc   = 4,
    ADC_CH_GAIN_16X_gc  = 5,
    ADC_CH_GAIN_32X_gc  = 6
}GAIN_t;

typedef enum RESOLUTION_ENUM
{
    ADC_8_BIT_gc    = 0,
    ADC_12_BIT_gc   = 1,
    ADC_14_BIT_gc   = 2,
    ADC_16_BIT_gc   = 3
}RES_t;

typedef enum SAMPLES_ENUM
{
    ADC_1_SAMPLE_gc     = 0,
    ADC_2_SAMPLES_gc    = 1,
    ADC_4_SAMPLES_gc    = 2,
    ADC_8_SAMPLES_gc    = 3,
    ADC_16_SAMPLES_gc   = 4,
    ADC_32_SAMPLES_gc   = 5,
    ADC_64_SAMPLES_gc   = 6,
    ADC_128_SAMPLES_gc  = 7,
    ADC_256_SAMPLES_gc  = 8,
    ADC_512_SAMPLES_gc  = 9
}SMPD_t;

typedef enum
{

  DIGFILT_1SAMPLE_gc  = 0,
  DIGFILT_2SAMPLES_gc = 1,
  DIGFILT_3SAMPLES_gc = 2,
  DIGFILT_4SAMPLES_gc = 3,
  DIGFILT_5SAMPLES_gc = 4,
  DIGFILT_6SAMPLES_gc = 5,
  DIGFILT_7SAMPLES_gc = 6,
  DIGFILT_8SAMPLES_gc = 7

}DIGFILT_t;

typedef enum
{

  PLOC_D1   =   0x28,
  PLOC_D2   =   0x29,
  PLOC_D3   =   0x2A,
  PLOC_D4   =   0x2B,
  PLOC_D5   =   0x2C,   //no index available at this position

  PLOC_D12  =   0x30,
  PLOC_D11  =   0x31,
  PLOC_D10  =   0x32  //no index available at this position

}PLOC_t;

typedef enum DAQ_STATE{
    DAQ_STOPPED_STATE   = 0,
    DAQ_INIT_STATE      = 1,
    DAQ_RUNNING         = 2,
    DAQ_BOOT_STATE      = 3
}DAQ_STATE_t;

#endif // UTIL_H
